﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    class Program01
    {
        static void Main(string[] args)
        {
            //Tiger t = new Tiger();
            //t.leg = 4;
            //t.Sleep();
            //t.Walk();
            //t.swim();
            //t.Shout();
            //t.Eat();

            //Console.WriteLine("------------------------------");

            //Cat c = new Cat();
            //c.leg = 4;
            //c.Sleep();
            //c.Walk();
            //c.CatchMouse();
            //c.Shout();
            //c.Eat();

            //Console.WriteLine("------------------------------");

            //Eagle e = new Eagle();
            //e.leg = 2;
            //e.Sleep();
            //e.Walk();
            //e.CatchChicken();
            //e.Shout();
            //e.Eat();

            //Console.WriteLine("------------------------------");

            //Swallow s = new Swallow();
            //s.leg = 2;
            //s.Sleep();
            //s.Walk();
            //s.Shout();
            //s.Eat();

            //Console.WriteLine("------------------------------");

            //PetStore ps = new PetStore();
            //Cat tom = new Cat();
            //ps.ConsignCat(tom);

            //Console.WriteLine("------------------------------");

            //Tiger Hu = new Tiger();
            //ps.ConsignTiger(Hu);

            //Console.WriteLine("------------------------------");

            //Eagle yan = new Eagle();
            //ps.ConsignEagle(yan);

            //Console.WriteLine("------------------------------");

            //Swallow huahua = new Swallow();
            //ps.ConsignSwallow(huahua);

            //多态的条件：1、继承；2、重写；3、父类的引用指向子类的实例；
            //Console.WriteLine("------------------------------");

            //Did d = new Eagle();
            //d.Cry();
            //多态应用：1、父类作为方法的形参；2、父类作为方法的返回值。
            Console.WriteLine("欢迎来到xx宠物店，请问你要寄存什么动物呢：1、猫；2、燕子；3、老鹰；4、老虎");
            int key = int.Parse(Console.ReadLine());
            Did d;
            switch (key)
            {
                case 1:
                    d = new Cat();
                    break;
                case 2:
                    d = new Swallow();
                    break;
                case 3:
                    d = new Eagle();
                    break;
                case 4:
                    d = new Tiger();
                    break;
                default:
                    Console.WriteLine("你别乱选。");
                    d = new Tiger();
                    break;
            }

            PetStore ps = new PetStore();
            ps.ConsignDid(d);
        }
    }
}
